package com.we.wecc.aw.api.controller;

import com.we.wecc.aw.db.model.Award;
import com.we.wecc.aw.mid.model.out.AwardOut;
import com.we.wecc.aw.mid.service.AwardService;
import com.x.share.api.controller.BaseController;
import com.x.share.db.model.Pagination;
import com.x.share.mid.exception.HelperException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@Api("活动期数接口")
@RestController
@RequestMapping("/wecc/aw")
public class AwardController extends BaseController{

    @Resource
    AwardService awardService;

    @ApiOperation(value = "获取各种状态活动", notes= "获取各种状态活动,djStatus(0未对奖 100已联系兑奖 200已签收)", response = AwardOut.class)
    @RequestMapping(value = "/getAwardList", method = { RequestMethod.GET})
    public @ResponseBody Map<String, Object> getAwardList(
            @ApiParam(value = "当前期活动状态0未开始100预热200进行中300兑奖中400未完成500结束", defaultValue = "500") @RequestParam("awardStatus") Integer awardStatus,
            @ApiParam(value = "当前页,默认第1页", defaultValue = "1") @RequestParam("pn") Integer pageNo,
            @ApiParam(value = "每页记录数", defaultValue = "5") @RequestParam("ps") Integer pageSize,
            @ApiParam(value = "应用id") @RequestHeader("appId") String appId,
            @ApiParam(value = "应用accessToken") @RequestHeader("atk") String atk) throws HelperException {
        Pagination<AwardOut> page = awardService.getAwardList(awardStatus, pageNo, pageSize);
        return success(page);
    }

    @ApiOperation(value = "获取本期", notes= "根据本期及获取当前热度", response = AwardOut.class)
    @RequestMapping(value = "/getCurrentAward", method = { RequestMethod.GET})
    public @ResponseBody Map<String, Object> getCurrentAward(
            @ApiParam(value = "应用id") @RequestHeader("appId") String appId,
            @ApiParam(value = "应用accessToken") @RequestHeader("atk") String atk) throws HelperException {
        AwardOut out = awardService.getCurrentAward();
        return success(out);
    }



}
